package org.csmzxy.class2333;

import java.util.Scanner;

public class Example04 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入第一个正整数：");
        int num1 = scanner.nextInt();
        System.out.println("请输入第二个正整数：");
        int num2 = scanner.nextInt();

        int gcd = finGCD(num1,num2);
        int lcm = (num1 * num2) / gcd;

        System.out.println(num1 + "和" + num2 + "的最大公约数是：" + gcd);
        System.out.println(num1 + "和" + num2 + "的最小公倍数是：" + lcm);

        scanner.close();
    }

    public static int finGCD(int a,int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }
}
